/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package noodlesscm;

import java.awt.Color;
import java.io.BufferedReader;
import java.io.FileReader;
import java.util.ArrayList;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;


public class viewProduct extends IGui{
    public  void viewProduct111(){


                                ArrayList<Product> p=new ArrayList<Product>();
                                p.add(new Product());
                                p.add(new Product());
                                p.add(new Product());
                                p.add(new Product());
                                p.add(new Product());
                                p.add(new Product());
                                p.add(new Product());


                                int id1[]= new int[20],i=0,total=0;
                                try
                                {
                                    frs=new FileReader("GUIItem.txt");
                                    br=new BufferedReader(frs);

                                    while((s=br.readLine()) != null)
                                    {
                                        total=total+1;
                                        cline=s.split(",");
                                        p.get(i).setName(cline[0]);
                                        p.get(i).setProductid(Integer.parseInt(cline[1]));
                                        p.get(i).setQuantity(Integer.parseInt(cline[2]));
                                        p.get(i).setDescription(cline[3]);
                                        p.get(i).setInvenlist(cline[4]);
                                        i++;

                                    }
                                    Object[] col = new Object[]{"Name","ProductID","Quantity","Description","InventoryList"};
                                    Object[][] data = {};
                                    DefaultTableModel model = new DefaultTableModel(data,col);
                                    JTable table = new JTable(model);
                                    JScrollPane pane = new JScrollPane(table);


                                    for(int n=0;n<i;n++)
                                        {
                                            System.out.println("Name :"+p.get(n).getName()+" ID "+p.get(n).getProductid()+" Quality "+p.get(n).getQuantity()+" Description "+p.get(n).getDescription()+" Inventory list "+p.get(n).getInvenlist());
                                            Object[] row1=new Object[]{p.get(n).getName(),p.get(n).getProductid(),p.get(n).getQuantity(),p.get(n).getDescription(),p.get(n).getInvenlist()};
                                            model.addRow(row1);
                                        }
                                    JFrame jfp=new JFrame("Product List");
                                    jfp.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
                                    jfp.setBackground(Color.white);
                                    jfp.setSize(600,300);
                                    jfp.setVisible(true);
                                    jfp.setLocation(200,200);
                                    jfp.add(pane);

                                }

		catch(Exception ex)
		{
			System.out.println("Error in currentinventory1");

		}
    }
}
